<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/11
 * Time: 19:52
 */
include '../classes/logincheck.php';
include "../classes/conn.php";
if(islogin()!='teacher_login'){
    die('error');
}
//判断要删除的班级是否存在
$query="select num from class where num='{$_POST['class_num']}'";
$res=mysql_query($query);

//判断要删除的学生是否存在
$query2="select * from student where class='{$_POST['class_num']}' and teacher='{$_SESSION['t_num']}'";
$res2=mysql_query($query2);
if(mysql_num_rows($res)>=1){
    $query="delete from class where num='{$_POST['class_num']}'";
    mysql_query($query);
    if(mysql_num_rows($res2)>=1){
        $query2="delete from student where class='{$_POST['class_num']}' and teacher='{$_SESSION['t_num']}'";
        mysql_query($query2);
        echo '1';
    }
    else echo 'no_stu';
}
else echo "error";